<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>用户管理</title>
	<!-- import css and js --> 
	<%@ include file="/common/metaInput.jsp" %>  
<script type="text/javascript">
var oldpassword="${oldpassword}";
$(function(){
	
	$("#branchname").change(function(){ 
		  $("#branch").val($("#branchname").find("option:selected").text());
		  $("#branchid").val($("#branchname").val());
	}); 
	
$("#inputForm").validate({			   
	onsubmit: true,
	 /*执行ajaxsubmit  */ 
    submitHandler: function(editform) {
            
        //alert(jsonInfo); 
        try{			    		
            url =  "${ctx}/security/user/save.do";
            var api = frameElement.api;
        	var W = api.opener;
        	if($("#id").val()!=""  && oldpassword!=$("#password").val()){//修改过密码
        		
        		if($("#cpassword").val()!=$("#password").val()){
        			$.dialog.alert("确认密码和密码输入不一致！");  
            		return ;
        		}
        		
        	}
        	if($("#id").val()==""){
        		if($("#cpassword").val()!=$("#password").val()){
        			$.dialog.alert("确认密码和密码输入不一致！");  
            		return ;
        		}
        	}
        
            getReturnMessage(url,"inputForm",W.searchAP);	
        }catch(e){alert(e)}
    }
 }
);
})
function submitForm(param){
	
    //设置ajax全局同步
	jQuery.ajaxSettings.async = false;
  	$("#submitFlag").val(param);
    $("#inputForm").submit();
 }		

	
</script>

</head>

<body>

<form id="inputForm" action="${ctx}/security/user/save.do" method="post">
<input type="hidden" id="id" name="id" value="${tttuser.id}"/>
<!-- 用于标识提交按钮 -->
<input type="hidden" id="submitFlag" value="" />
 <div class="pageContent" >
    <div class="panel">
         <table class="TableBlock" align="center">
                
                   <tr>
   		                 <td nowrap>登录名:</td>
   		                 <td colspan="3"><input id="name"   <c:if test="${!empty tttuser.enabled}">readonly="readonly"</c:if>  name="name" class="required" value="${tttuser.name}" /></td>
   		                 
   		           </tr>
   		           <tr>
   		           <td nowrap>姓名:</td>
   		                 <td colspan="3">
   		                 <input id="realname" name="realname" class="required" value="${tttuser.realname}" />
   		                 </td>	
   		           </tr>
   		             <tr>
   		                 <td nowrap>密码:</td>
   		                 <td colspan="3" ><input type="password" id="password" class="required" name="password"  value="${tttuser.password}" /></td>
   		           		
   		           </tr>
                 	<tr>
                 		 <td nowrap>确认密码:</td>
   		                 <td colspan="3" ><input id="cpassword"  type="password" name="cpassword"  class="required" /></td>
                 	</tr>
   		          
   		           <tr>
   		            <td nowrap>部门:</td>
   		            <td colspan="3" ><select id="branchname" name="branchname" class="required">
                    			<option></option>
                    			<c:forEach var="dbd" items="${bddlist }">
                    				<option value="${dbd.id }">${dbd.depname }</option>
                    			</c:forEach>
                    		</select>
                    		<input type="hidden" id="branchid" name="branchid" value="${tttuser.branchid}"/>
                    		<input type="hidden" id="branch" name="branch" value="${tttuser.branch}"/>
                    		<script type="text/javascript">
                    			$("#branchname").val('${tttuser.branchid}');
                    		</script></td>   
   		           </tr>
   		            <tr> 
   		            <td nowrap>状态:</td>
   		                 <td colspan="3">	<input type="radio" name="enabled" value="1" <c:if test="${tttuser.enabled==1 || empty tttuser.enabled}">checked="checked"</c:if> />激活
   		                 	<input type="radio" name="enabled" value="0" <c:if test="${tttuser.enabled==0}">checked="checked"</c:if> />冻结</td>	
   		           </tr>
                </table>               
         </div>
         <div class="formBar">
	        <ul>
		       <li><div class="buttonActive"><div class="buttonContent"><button type="button" id="save" onclick="submitForm(1)">保存</button></div></div></li>
		       <li><div class="button"><div class="buttonContent"><button type="button" class="print" onclick="CloseDialog()">关闭</button></div></div></li>
	        </ul>
        </div>    
    </div>
</form>
</body>
</html>
